package com.zlx.redismessage.producer.impl;

import com.zlx.redismessage.producer.BaseProducer;
import com.zlx.redismessage.util.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * @PackageName: com.goayuan.learn.mq.producer.modules.redis
 * @ClassName: RedisProducer
 * @Author: gaoYuan
 * @Date: 2022/2/24 13:10
 * @Description: RedisProducer
 */
@Service
public class RedisProducerImpl implements BaseProducer {

    private static Logger log = LoggerFactory.getLogger(RedisProducerImpl.class);


    @Override
    public void sendMsg(String queue, String msg) {
        try {
			RedisUtils.getRedisTemplate().opsForList().leftPush(queue, msg);
        } catch (Exception e) {
            log.error("redis 连接异常后重试");
			RedisUtils.getRedisTemplate().opsForList().leftPush(queue, msg);
        }
    }
}
